<?php
/**
 *
 * @category   JND
 * @package    Jnd_View
 * @subpackage Helper
 * @copyright  Copyright (c) 2005-2009 DDB
 * @version    $Id: FormDatePicker.php 16541 2009-10-12 17:02:30Z tbrouard $
 */
/**
 * Abstract class for extension
 */
require_once 'Zend/View/Helper/FormElement.php';
/**
 * Helper to generate a "datePicker" element
 *
 * @category Jnd
 * @package Jnd_View
 * @subpackage Helper
 */
class Jnd_View_Helper_FormDatePicker extends Zend_View_Helper_FormElement {
	
	/**
	 * Generates a 'hidden' element.
	 *
	 * @access public
	 *        
	 * @param string|array $name
	 *        	If a string, the element name. If an
	 *        	array, all other parameters are ignored, and the array
	 *        	elements
	 *        	are extracted in place of added parameters.
	 * @param mixed $value
	 *        	The element value.
	 * @param array $attribs
	 *        	Attributes for the element tag.
	 * @return string The element XHTML. div tag + input hidden tag
	 */
	public function formDatePicker($name, $value = null, array $attribs = null) {
		$info = $this->_getInfo ( $name, $value, $attribs );
		extract ( $info ); // name, value, attribs, options, listsep, disable
		if (isset ( $id )) {
			if (isset ( $attribs ) && is_array ( $attribs )) {
				$attribs ['id'] = $id;
			} else {
				$attribs = array (
						'id' => $id 
				);
			}
		} else {
			$attribs ['id'] = $name;
		}
		if (strpos ( $name, "-" ) !== FALSE) {
			$name = str_replace ( $name, "-", "[" ) . "]";
		}
		$attribs ['name'] = $name;
		// echo "Name (formDatePicker) : " . $attribs['name'] . "<br />";
		$view = Zend_Controller_Front::getInstance ()->getParam ( 'bootstrap' )->getResource ( "view" );
		$view->jQuery ()->addJavascriptFile ( '/js/datepicker/jquery.datepick-fr.js' );
		$jquery = Jnd_App::getConfig ( 'jquery' );
		$jqueryServeurUrl = $jquery ['path'] ['min'];
// 		$view->jQuery ()->addStylesheet ( $jqueryServeurUrl . 'css/dark-hive/jquery-ui-1.8.Autocomplete.Datepicker.css' );
		return $view->datePicker ( $name, $value, $attribs, $attribs );
	}
}
